/******************************************************************************
 *                                                                            *
 *               (c) 2008-2009 HutLab. All rights reserved.                   *
 *                        Eduardo Henrique Leite                              *
 *                                                                            *
 ******************************************************************************

 History:
 Created 05/01/2009

 */

package hutlab.sudoku.engine.ai;

import hutlab.sudoku.engine.base.*;

/**
 *
 */
public class SudokuCell {

    // ----- FIELDS -----

    private int mRow;
    private int mColumn;
    private int mValue = 0;
    private IntegerList mPossibilities;

    // ----- GETTERS -----

    public int getRow(){
        return mRow;
    }

    public int getColumn(){
        return mColumn;
    }

    public int getValue(){
        return mValue;
    }

    public IntegerList getPossibilities(){
        return mPossibilities;
    }

    // ----- SETTERS -----

    public void setRow(int row){
        mRow = row;
    }

    public void setColumn(int col){
        mColumn = col;
    }

    public void serPossibilities(IntegerList possibilities){
        mPossibilities = possibilities;
    }

    public void setValue(int value){
        if (this.mPossibilities.contains(value)){
            this.mValue = value;
            this.mPossibilities.clear();
        }
    }

    // ----- PUBLIC -----

    public boolean validate(){
        return (this.mValue > 0 && this.mValue <= 9);
    }    

    public void removePossibility(int value){
        if (this.mPossibilities.contains(value)){
            this.mPossibilities.remove(value);
        }
    }

    // ----- STATIC -----

    private static IntegerList defaultPossibilityList(){
        IntegerList possibilities = new IntegerList();

        for (int i = 1; i <= 9; i++){
            possibilities.add(i);
        }

        return possibilities;
    }

    // ----- CONSTRUCTOR -----

    public SudokuCell(int row, int column){
        this.mRow = row;
        this.mColumn = column;
        this.mPossibilities = defaultPossibilityList();
    }
}
